﻿package com.glidecast.models
{
	import flash.events.EventDispatcher;
	
	import flash.events.Event;
	
	import com.glidecast.models.Content;
	import com.glidecast.models.Template;
	import com.glidecast.models.Audio;
	import com.glidecast.models.Graphic;
	
	public class Segment extends EventDispatcher
	{
		public static var UPDATE:String='SegmentUpdated';
		
		
		public function Segment()
		{	
		}
		
		private var _name:String='';
		public function get name():String
		{
			return _name;
		}
		public function set name(s:String):void
		{
			_name=s;
			dispatchEvent(new Event(Segment.UPDATE));			
		}
		
		private var _duration:String='';
		public function get duration():String
		{
			return _duration;
		}
		public function set duration(s:String):void
		{
			_duration=s;
			dispatchEvent(new Event(Segment.UPDATE));			
		}
		
		//TODO: Turn this String type into an enumeration. None, Loop, Random
		private var _repeat:String='';
		public function get repeat():String
		{
			return _repeat;
		}
		public function set repeat(s:String):void
		{
			_repeat=s;
			dispatchEvent(new Event(Segment.UPDATE));			
		}
		/*
			Content items are the RSS feeds or raw text which 
			are plugged into the template of the segment. There
			may be more than 1 content item.
		*/
		
		private var _contents: Array;
		public function get contents():Array
		{
			return this._contents;
		}
		public function set contents(newContents: Array): void
		{
			this._contents=newContents;
		}
		
		private var _template:Template;
		public function get template():Template
		{
			return _template;
		}
		public function set template(s:Template):void
		{
			_template=s;
			dispatchEvent(new Event(Segment.UPDATE));			
		}
		
		private var _audio:Audio;
		public function get audio():Audio
		{
			return _audio;
		}
		public function set audio(s:Audio):void
		{
			_audio=s;
			dispatchEvent(new Event(Segment.UPDATE));			
		}
		
		private var _graphic:Graphic;
		public function get graphic():Graphic
		{
			return _graphic;
		}
		public function set graphic(s:Graphic):void
		{
			_graphic=s;
			dispatchEvent(new Event(Segment.UPDATE));			
		}
		private var _lastModified:Date;
		public function get lastModified():Date
		{
			return _lastModified;
		}
		public function set lastModified(s:Date):void
		{
			_lastModified=s;
		}
	}
}
